from http import HTTPStatus
import dashscope


def call_with_messages():
    messages = [{'role': 'system', 'content': '你需要理解我说的话并换个表达方式复述一遍，复述字数不能少于原句'},
                {'role': 'user', 'content': '随着科技的进步和全球经济的不断发展,金融会计业也面临着前所未有的机遇与挑战。'}]

    response = dashscope.Generation.call(
        dashscope.Generation.Models.qwen_turbo,
        messages=messages,
        api_key='sk-cd0a7b8991f141ea86491a454247a232',
        result_format='message',  # set the result to be "message" format.
    )
    if response.status_code == HTTPStatus.OK:
        print(response)
    else:
        print('Request id: %s, Status code: %s, error code: %s, error message: %s' % (
            response.request_id, response.status_code,
            response.code, response.message
        ))


if __name__ == '__main__':
    call_with_messages()
